-
Notifications
You must be signed in to change notification settings - Fork 474
scalafmt: version from the config file is not dynamically used #2460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Happy to take any PRs that improve the situation, but I lean towards the idea that it should be an error if the versions disagree. Of all fixes, the easiest to implement is probably just a precondition check that gives a nice error message if the version in the config file exists and is different than the version Spotless is using. |
@nedtwigg indeed, sounds like a reasonable way to avoid the error and easy and future-proof to implement. I'll give it a try then :) |
I'm not familiar with the codebase, should the check be implemented in I was going for |
Either would work fine. |
Uh oh!
There was an error while loading. Please reload this page.
Scalafmt binaries (JARs) are supposed to parse the version declared in the config file and use this version to dynamically download the appropriate scalafmt release to then run.
This behaviour works fine in with sbt or IDEs but it doesn't seem to work with Spotless: the version declared in the config file (
.scalafmt.conf
) is not used.Reproduction case
Have the following
.scalafmt.conf
:And in the
pom.xml
(Maven):Then, running
mvn spotless:apply
works fine.Now, change the version in the POM to
3.4.0
which doesn't support anymore theunindentTopLevelOperators
key,mvn spotless:apply
fails:Whereas it should have run in "3.2.0 mode" because it's the version specified in the config file.
References
https://scalameta.org/scalafmt/docs/configuration.html#version
Possible fixes
Scalafmt uses a "scalafmt-dynamic" JAR to do this. My guess is that Spotless doesn't use it.
They document how to use it from Java: https://scalameta.org/scalafmt/docs/installation.html#calling-from-java
Additional info
I guess the other way around may also happen: in the config file has a newer version than the one declared in the POM.
IMHO, in medium term, the POM version should be removed (it's already optional) and it should aways use the default version hardcoded in Spotless to then dynamically download the version mentioned in the config file.
The text was updated successfully, but these errors were encountered: